<?php
namespace App\Http\Controllers\Validator;
use Validator;

/**
 * Class UserVali
 * @package App\Http\Controllers\Validator
 * 用户表验证器
 */
class UserVali{

    public static function validate($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'u_d_id'             => 'required',//部门ID
            'u_username'         => 'required',//员工姓名
//            'u_account_number'   => 'required|unique:user',  //员工的登录账号
            'u_password'         => 'required',//密码
            'sex'                => 'required',//性别
            'birthday'           => 'required',//生日
//            'jiguan'             => 'required',//籍贯
//            'nation'             => 'required',//民族
//            'college'            => 'required',//毕业院校
//            'political_face'     => 'required',//政治面貌
//            'speciality'         => 'required',//所学专业
            'record_type'        => 'required',//学历
//            'people_num'         => 'required',//身份证号
            'phone'              => 'required',//联系电话
//            'email'              => 'required',//邮箱
            'address'            => 'required',//家庭住址
//            'bank_num'           => 'required',//银行账号
//            'bank_remark'        => 'required',//银行名字
//            'personal_profile'   => 'required',//个人简介
            'post'               => 'required',//职务
            'source'             => 'required',//来源
//            'remark'             => 'required',//备注
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    public static function saveValidate($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'u_id'               => 'required',//员工ID
            'u_d_id'             => 'required',//部门ID
            'u_username'         => 'required',//员工姓名
            'sex'                => 'required',//性别
            'birthday'           => 'required',//生日
            'u_status'           => 'required',//账号状态（1正常（审核通过） 2禁用(审核中）3.离职）
            'record_type'        => 'required',//学历
            'phone'              => 'required',//联系电话
            'address'            => 'required',//家庭住址
            'post'               => 'required',//职务
            'source'             => 'required',//来源
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    public static function loginValidate($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'u_account_number'        => 'required',
            'u_password'   => 'required',
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    /**员工修改自己密码  字段验证
     * @param $params
     * @return bool
     */
    public static function updatePassword($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'new_password'   => 'required',
            'again_password' => 'required',
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    /**修改员工的权限
     * @param $params
     * @return bool
     */
    public static function updatePermission($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'u_id'   => 'required',
            'authories' => 'required',
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    /**
     * 处理跟进提醒 验证
     */
    public static function updateFollow($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'cfs_id'   => 'required',
            'type' => 'required',
            'id' => 'required',
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }
}